<!-- Password strength checker scripts -->
<?php e($javascript->link('jquery/jquery.pstrength', false)); ?>
<!-- Password form -->
<div class="users form" style="width: 60%">
<?php e($form->create('User', array('action' => 'password')));?>
    <fieldset>
        <legend><?php __('Change Password');?></legend>
        <?php e($form->input('newpassword', array(
                            'label'=>__('New password', true),
                            'title'=>__('At least 6 characters combined with letters and numbers only', true),
                            'type'=>'password',
                            'class' => 'password input'))); ?>
        <?php e($form->input('newpasswordconfirm', array(
                            'label'=>__('Confirm new password', true),
                            'title'=>__('Password confirm, which must be exactly the same as the above one', true),
                            'type'=>'password',
                            'class' => 'password input'))) ?>
        <?php e($form->submit(__('Save Changes', true), array('class' => 'submit attention'))); ?>
    </fieldset>
<?php e($form->end()); ?>
</div>
<script type="text/javascript">
jQuery(function(){
    $('#UserNewpassword').pstrength();
    // Validate Change password form
    $('#UserPasswordForm').clearForm().validate({
        rules: {
            'data[User][newpassword]': 'required',
            'data[User][newpasswordconfirm]': 'required'
        },
        messages: {
            'data[User][newpassword]': { required: '请不要将新密码设置为空值' },
            'data[User][newpasswordconfirm]': { required: '确认密码应该和新密码相同'}
        }
    });
    $('#UserPasswordForm input.submit').click(function(event){
        //event.preventDefault();
        if(!$('#UserPasswordForm').valid()){ return false; }
        if($('input#UserNewpassword').val() != $('input#UserNewpasswordconfirm').val()){
            $.log('Submit with different passwords, drop the request');
            $.sme.notify('error', '两次输入的密码不一致');
            return false;
        }
    });
    /* Input tips */
    $('input').tooltip({
        position: 'center right',
        offset: [10, 0],
        tip: '#tooltip',
        lazy: false,
        effect: 'slide'
    }).dynamic({
        right: {
            direction: 'down',
            bounce: true
        }
    });
});
</script>